<html><head><title>Extract Predictor Values and Standard Errors For New Data In a GAMLSS Model</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="Rchm.css">
</head>
<body>

<table width="100%"><tr><td>predict.gamlss(gamlss)</td><td align="right">R Documentation</td></tr></table><object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
<param name="keyword" value="R:   predict.gamlss">
<param name="keyword" value="R:   predictAll">
<param name="keyword" value=" Extract Predictor Values and Standard Errors For New Data In a GAMLSS Model">
</object>


<h2>Extract Predictor Values and Standard Errors For New Data In a GAMLSS Model</h2>


<h3>Description</h3>

<p>
<code>predict.gamlss</code> is the GAMLSS specific method which produce predictors for a new data set   
for a specified parameter from a GAMLSS objects.  
The <code>predict.gamlss</code> can be used to extract the linear predictors, fitted values and specific  terms in the model at new 
data values in the same way that the <code>predict.lm()</code> and <code>predict.glm()</code> functions can be used for 
<code>lm</code> or <code>glm</code> objects. Note that linear predictors, fitted values and specific terms in the model at the current  
data values can also be extracted using the function <code>lpred()</code> (which is called from predict if new data is NULL).
</p>


<h3>Usage</h3>

<pre>
## S3 method for class 'gamlss':
predict(object, what = c("mu", "sigma", "nu", "tau"), 
               newdata = NULL, type = c("link", "response", "terms"), 
               terms = NULL, se.fit = FALSE, data = NULL, ...)
predictAll(object, newdata = NULL, type = c("response", "link", "terms"), 
               terms = NULL, se.fit = FALSE, ...)

</pre>


<h3>Arguments</h3>

<table summary="R argblock">
<tr valign="top"><td><code>object</code></td>
<td>
a GAMLSS fitted model</td></tr>
<tr valign="top"><td><code>what</code></td>
<td>
which distribution parameter is required, default <code>what="mu"</code></td></tr>
<tr valign="top"><td><code>newdata</code></td>
<td>
a data frame containing new values for the explanatory variables used in the model</td></tr>
<tr valign="top"><td><code>type</code></td>
<td>
the default, gets the linear predictor for the specified distribution parameter. 
<code>type="response"</code> gets the fitted values for the parameter while <code>type="terms"</code> gets the fitted terms contribution</td></tr>
<tr valign="top"><td><code>terms</code></td>
<td>
if <code>type="terms"</code>, which terms to be selected (default is all terms)</td></tr>
<tr valign="top"><td><code>se.fit</code></td>
<td>
if TRUE the approximate standard errors of the appropriate type are extracted if exist</td></tr>
<tr valign="top"><td><code>data</code></td>
<td>
the data frame used in the original fit if is not defined in the call</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
for extra arguments </td></tr>
</table>

<h3>Details</h3>

<p>
The predict function  assumes that the object given in <code>newdata</code> is a data frame containing the right x-variables
used in the model. This could possible cause problems if transformed variables are used in the fitting of the original model.
For example, let us assume that a transformation of age is needed in the model i.e. <code>nage&lt;-age^.5</code>. This could be fitted as 
<code>mod&lt;-gamlss(y~cs(age^.5),data=mydata)</code> or as  <code>nage&lt;-age^.5;  mod&lt;-gamlss(y~cs(nage), data=mydata)</code>.
The later could more efficient if the data are in thousands rather in hundreds. In the first case,   
the code <code>predict(mod,newdata=data.frame(age=c(34,56)))</code> would produce the right results.  
In the second case a new data frame has to be created containing the old data plus any new transform data. This data frame has to 
be declared in the <code>data</code> option. The option <code>newdata</code> should 
contain a data.frame with the new names and the transformed values in which prediction is required, (see the last example).
</p>


<h3>Value</h3>

<p>
A vector or a matrix  depending on the options.</p>

<h3>Note</h3>

<p>
This function is under development
</p>


<h3>Author(s)</h3>

<p>
Mikis Stasinopoulos
</p>


<h3>References</h3>

<p>
Rigby, R. A. and  Stasinopoulos D. M. (2005). Generalized additive models for location, scale and shape,(with discussion), 
<EM>Appl. Statist.</EM>, <B>54</B>, part 3, pp 507-554.
</p>
<p>
Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use the GAMLSS package in R.
Accompanying documentation in the current GAMLSS  help files, (see also  <a href="http://www.gamlss.com/">http://www.gamlss.com/</a>). 
</p>
<p>
Stasinopoulos D. M. Rigby R.A. (2007) Generalized additive models for location scale and shape (GAMLSS) in R.
<EM>Journal of Statistical Software</EM>, Vol. <B>23</B>, Issue 7, Dec 2007, <a href="http://www.jstatsoft.org/v23/i07">http://www.jstatsoft.org/v23/i07</a>.
</p>


<h3>See Also</h3>

<p>
<code><a href="lpred.html">lp</a></code>,  <code><a href="lpred.html">lpred</a></code>
</p>


<h3>Examples</h3>

<pre>
data(aids)
a&lt;-gamlss(y~poly(x,3)+qrt, family=PO, data=aids) # 
newaids&lt;-data.frame(x=c(45,46,47), qrt=c(2,3,4))
ap &lt;- predict(a, newdata=newaids, type = "response")
ap
# now getting all the parameters
predictAll(a, newdata=newaids)
rm(a, ap)
data(abdom)
# transform x 
aa&lt;-gamlss(y~cs(x^.5),data=abdom)
# predict at old values
predict(aa)[610]
# predict at new values 
predict(aa,newdata=data.frame(x=42.43))
# now transform x first 
nx&lt;-abdom$x^.5
aaa&lt;-gamlss(y~cs(nx),data=abdom)
# create a new data frame 
newd&lt;-data.frame( abdom, nx=abdom$x^0.5)
# predict at old values
predict(aaa)[610]
# predict at new values 
predict(aaa,newdata=data.frame(nx=42.43^.5), data=newd)
</pre>



<hr><div align="center">[Package <em>gamlss</em> version 1.8-2 <a href="00Index.html">Index]</a></div>

</body></html>
